package com.zxx.mvpPractice.ui.activitys;

import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

import com.google.common.base.Preconditions;
import com.zxx.mvpPractice.R;
import com.zxx.mvpPractice.base.BaseActivity;
import com.zxx.mvpPractice.component.ImageLoader;
import com.zxx.mvpPractice.presenter.WelComePresenter;
import com.zxx.mvpPractice.presenter.contract.WelComeContract;
import com.zxx.mvpPractice.utils.JumpUtil;
import com.zxx.mvpPractice.utils.StringUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/12/22 0022.
 */

public class WelcomeActivity extends BaseActivity<WelComeContract.Presenter> implements WelComeContract.View {


    @BindView(R.id.iv_welcome_bg)
    ImageView ivWelcomeBg;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        unbinder = ButterKnife.bind(this);
        mPresenter = new WelComePresenter(this);
    }

    @Override
    public void showContent(List<String> list) {
        if (list != null) {
            int page = StringUtils.getRandomNumber(0, list.size() - 1);
            ImageLoader.load(this, list.get(page), ivWelcomeBg);
            ivWelcomeBg.animate().scaleX(1.12f).scaleY(1.12f).setDuration(2000).setStartDelay(100).start();
        }
    }

    @Override
    public void jumpToActivity() {
//要判断是跳转登录还是直接进首页
        JumpUtil.go2RegisterLoginActivity(this);
//        JumpUtil.go2MainActivity(mContext);
        overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        finish();
    }

    @Override
    public void setPresenter(WelComeContract.Presenter presenter) {
        mPresenter = Preconditions.checkNotNull(presenter);
    }

    @Override
    public void showError(String msg) {
        Log.d("zxx", "showError:" + msg);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

    }
}
